package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.product.ProductFeign;
import com.atguigu.gmall.model.to.BaseCategroysTo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/8/29 0:43
 */
@Slf4j
@Controller
public class IndexController {
    @Autowired
    private ProductFeign productFeign;

    @GetMapping({"/","index.html"})
    public String index(Model model) {
        log.info("访问首页");
        List<BaseCategroysTo> result = productFeign.getCategoryAndChildrens();
        model.addAttribute("list", result);

        return "index/index";
    }
}
